retrieving date from sqlserver

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default retrieving date from sqlserver

    I have date in this form stored in sqlserver 2004-01-29 10:24:41.000, when I
    retrive it using formatdatetime vb function I get output as 12/30/99..

    Any ideas please...



    Girish Guest

  2. Similar Questions and Discussions

    1. Switch from SqlServer
      We do a lot of ETL using DTS. I'm new to Mysql and wonder what options it has to perform these tasks. The data is extracted from the host system to...
    2. [Macromedia][SQLServer JDBC Driver][SQLServer]Internal
      I'm running an export process which takes data and dumps it to a text file. The query used to build it can contain large amounts of information in...
    3. Win32::SqlServer 2.001
      Two weeks ago I announced MSSQL::OlleDB 2.000. That name was not popular with the people on the Perl module list (since the module is Windows-only),...
    4. Connecting ASP.NET to SQLServer,Somebody,Please!!
      It is now 3 months that we are trying to connect ASP.NET to a SQLServer located on another system However we act,we get a fatal error We need...
    5. Adapt date from Oracle to SQLServer
      Aaron Bertrand - MVP wrote: Thnaks a lot, I'll adapt the function. Good Idea :) -- Direct access to this group with http://web2news.com...
  3. #2

    Default Re: retrieving date from sqlserver

    Girish wrote:
    > I have date in this form stored in sqlserver 2004-01-29 10:24:41.000,
    No. Unless you are storing it in a char or varchar column, it is NOT stored
    in this form. Datetimes are stored as paired integers, the first containing
    the number of days since the seed date, and the second containing the number
    of milliseconds since midnight. All formatting is done by the client
    application which displays the date
    > when I retrive it using formatdatetime vb function I get output as
    > 12/30/99..
    >
    > Any ideas please...
    Show us the code.

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  4. #3

    Default Re: retrieving date from sqlserver

    Girish wrote:
    > I have date in this form stored in sqlserver 2004-01-29 10:24:41.000,
    > when I retrive it using formatdatetime vb function I get output as
    > 12/30/99..
    >
    > Any ideas please...
    Actually, ignore my last post: don't show us the code. Instead, go to
    [url]www.aspfaq.com[/url] and search for "date". You will find several articles about
    using dates.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  5. #4

    Default Re: retrieving date from sqlserver

    On Thu, 29 Jan 2004 12:36:41 -0800, "Girish" <girishkiss@yahoo.com>
    wrote:
    >I have date in this form stored in sqlserver 2004-01-29 10:24:41.000, when I
    >retrive it using formatdatetime vb function I get output as 12/30/99..
    Is it a Date/Time data type in SQL? Or a text field? Are you sure
    you have the correct FormatDateTime syntax? Show the code snippet,
    and/or check:

    [url]http://www.devguru.com/Technologies/vbscript/quickref/formatdatetime.html[/url]

    Jeff
    Jeff Cochran Guest

  6. #5

    Default Re: retrieving date from sqlserver

    It is smalldatetime DATA TYPE, in one scenario I just want date and the
    other both date and time in one shot, I followed your URL there you are
    passing either date or time where as me I am passing both so.....

    "Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    news:403078e7.30692773@msnews.microsoft.com...
    > On Thu, 29 Jan 2004 12:36:41 -0800, "Girish" <girishkiss@yahoo.com>
    > wrote:
    >
    > >I have date in this form stored in sqlserver 2004-01-29 10:24:41.000,
    when I
    > >retrive it using formatdatetime vb function I get output as 12/30/99..
    >
    > Is it a Date/Time data type in SQL? Or a text field? Are you sure
    > you have the correct FormatDateTime syntax? Show the code snippet,
    > and/or check:
    >
    > [url]http://www.devguru.com/Technologies/vbscript/quickref/formatdatetime.html[/url]
    >
    > Jeff

    Girish Guest

  7. #6

    Default Re: retrieving date from sqlserver

    On Thu, 29 Jan 2004 14:02:42 -0800, "Girish" <girishkiss@yahoo.com>
    wrote:
    >It is smalldatetime DATA TYPE, in one scenario I just want date and the
    >other both date and time in one shot, I followed your URL there you are
    >passing either date or time where as me I am passing both so.....
    So.... What?

    You're not "passing" anything, you're retrieving a field in a record
    from your database and formatting what you retrieve. Try something
    like:

    SelectedDate = SELECT MyDateField FROM TableWithDateField
    MyDate = FormatDateTime(SelectedDate,0)
    Response.Write MyDate

    Or...

    SelectedDate = SELECT MyDateField FROM TableWithDateField
    MyDate = FormatDateTime(SelectedDate,2)
    MyTime = FormatDateTime(SelectedDate,3)
    Response.Write MyDate & " " & MyTime

    You get the idea. You'll need to tweak the SQL for your own database
    and connection of course.

    And read the ASPFAQ items suggested by Ray for other trickery with
    dates and times.

    Jeff
    >"Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    >news:403078e7.30692773@msnews.microsoft.com...
    >> On Thu, 29 Jan 2004 12:36:41 -0800, "Girish" <girishkiss@yahoo.com>
    >> wrote:
    >>
    >> >I have date in this form stored in sqlserver 2004-01-29 10:24:41.000,
    >when I
    >> >retrive it using formatdatetime vb function I get output as 12/30/99..
    >>
    >> Is it a Date/Time data type in SQL? Or a text field? Are you sure
    >> you have the correct FormatDateTime syntax? Show the code snippet,
    >> and/or check:
    >>
    >> [url]http://www.devguru.com/Technologies/vbscript/quickref/formatdatetime.html[/url]
    >>
    >> Jeff
    >
    Jeff Cochran Guest

  8. #7

    Default Re: retrieving date from sqlserver

    > SelectedDate = SELECT MyDateField FROM TableWithDateField
    > MyDate = FormatDateTime(SelectedDate,0)
    > Response.Write MyDate
    Huh? And there i was thinking you might need a connection object or even a
    recordset <g>

    --
    John Blessing

    [url]http://www.LbeHelpdesk.com[/url] - Help Desk software priced to suit all
    businesses
    [url]http://www.free-helpdesk.com[/url] - Completely free help desk software !
    [url]http://www.lbetoolbox.com[/url] - Remove Duplicates from MS Outlook
    "Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    news:4038863d.34106993@msnews.microsoft.com...
    > On Thu, 29 Jan 2004 14:02:42 -0800, "Girish" <girishkiss@yahoo.com>
    > wrote:
    >
    > >It is smalldatetime DATA TYPE, in one scenario I just want date and the
    > >other both date and time in one shot, I followed your URL there you are
    > >passing either date or time where as me I am passing both so.....
    >
    > So.... What?
    >
    > You're not "passing" anything, you're retrieving a field in a record
    > from your database and formatting what you retrieve. Try something
    > like:
    >
    > SelectedDate = SELECT MyDateField FROM TableWithDateField
    > MyDate = FormatDateTime(SelectedDate,0)
    > Response.Write MyDate
    >
    > Or...
    >
    > SelectedDate = SELECT MyDateField FROM TableWithDateField
    > MyDate = FormatDateTime(SelectedDate,2)
    > MyTime = FormatDateTime(SelectedDate,3)
    > Response.Write MyDate & " " & MyTime
    >
    > You get the idea. You'll need to tweak the SQL for your own database
    > and connection of course.
    >
    > And read the ASPFAQ items suggested by Ray for other trickery with
    > dates and times.
    >
    > Jeff
    >
    > >"Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
    > >news:403078e7.30692773@msnews.microsoft.com...
    > >> On Thu, 29 Jan 2004 12:36:41 -0800, "Girish" <girishkiss@yahoo.com>
    > >> wrote:
    > >>
    > >> >I have date in this form stored in sqlserver 2004-01-29 10:24:41.000,
    > >when I
    > >> >retrive it using formatdatetime vb function I get output as 12/30/99..
    > >>
    > >> Is it a Date/Time data type in SQL? Or a text field? Are you sure
    > >> you have the correct FormatDateTime syntax? Show the code snippet,
    > >> and/or check:
    > >>
    > >>
    [url]http://www.devguru.com/Technologies/vbscript/quickref/formatdatetime.html[/url]
    > >>
    > >> Jeff
    > >
    >

    John Blessing Guest

  9. #8

    Default Re: retrieving date from sqlserver

    On Thu, 29 Jan 2004 22:50:17 -0000, "John Blessing"
    <jb@**REMOVE**THIS**LbeHelpdesk.com> wrote:
    >> SelectedDate = SELECT MyDateField FROM TableWithDateField
    >> MyDate = FormatDateTime(SelectedDate,0)
    >> Response.Write MyDate
    >
    >Huh? And there i was thinking you might need a connection object or even a
    >recordset <g>
    Probably the reason I posted this line as well:
    > You get the idea. You'll need to tweak the SQL for your own database
    > and connection of course.
    If someone needs me to write the entire page I'll be happy to when I
    get the time, or when I get my usually exhorbitant fee... :)

    Jeff

    Jeff Cochran Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139