Dates in SQL Server

Discussion in 'ASP General' started by JP SIngh, Aug 2, 2005.

  1. JP SIngh

    JP SIngh Guest

    I have a SQL Database with an ASP front end.

    There are actually two webservers which connect to the SQL database in UK.

    i have two questions

    1. How can I insert null values when inserting dates within my records. If
    gives me a type mismatch error is the form field was empty.

    2. How will the sql server differentiate that the date coming from UK
    webserver example "03/01/2005" is 3rd January 2005 and the same date coming
    from US webserver "03/01/2005" is 1st March 2005. Do I need to deal with
    this in the ASP code? or maybe I need to convert them to a more generic
    format. Does anyone know of a fool proof function to convert the dates into
    universal formats.

    Thanks in advance for your help.

    Regards
     
    JP SIngh, Aug 2, 2005
    #1
    1. Advertising

  2. JP SIngh wrote:
    > I have a SQL Database with an ASP front end.
    >
    > There are actually two webservers which connect to the SQL database
    > in UK.
    >
    > i have two questions
    >
    > 1. How can I insert null values when inserting dates within my
    > records. If gives me a type mismatch error is the form field was
    > empty.


    Pass Null if the form field is empty

    >
    > 2. How will the sql server differentiate that the date coming from UK
    > webserver example "03/01/2005" is 3rd January 2005 and the same date
    > coming from US webserver "03/01/2005" is 1st March 2005. Do I need to
    > deal with this in the ASP code? or maybe I need to convert them to a
    > more generic format. Does anyone know of a fool proof function to
    > convert the dates into universal formats.
    >


    http://www.aspfaq.com/show.asp?id=2040 help with dates
    http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion
    http://www.aspfaq.com/show.asp?id=2313 vbscript


    HTH,
    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 [MVP], Aug 2, 2005
    #2
    1. Advertising

  3. > 2. How will the sql server differentiate that the date coming from UK
    > webserver example "03/01/2005" is 3rd January 2005 and the same date
    > coming
    > from US webserver "03/01/2005" is 1st March 2005.


    Don't use silly and ambiguous date formats. Pass YYYYMMDD. The database
    won't get confused, nor will any of your users.

    http://www.aspfaq.com/2023
     
    Aaron Bertrand [SQL Server MVP], Aug 2, 2005
    #3
  4. JP SIngh

    SP Guest

    SQL Server will store dates in its format, as long as it's a valid date
    format, SQL Server should recognize it when doing updates or inserts.
    For example
    "Update myTable set myDatetime = " & cdate(strDateEntered) & "where id = " &
    Idnumber

    The presentation is, just that... formatting data on display.
    when you pull your date from the database you should just format it in the
    way you want to view it.
    for example
    "Select convert(varchar(10),myDatetime,1) as MyDate FROM MyTable where Id =
    " & IdNumber

    in this case you will see the MyDate displayed as "MM/DD/YY" of course there
    are other format options so have fun playing with them.

    Cheers,

    SP


    "JP SIngh" <> wrote in message
    news:...
    >I have a SQL Database with an ASP front end.
    >
    > There are actually two webservers which connect to the SQL database in UK.
    >
    > i have two questions
    >
    > 1. How can I insert null values when inserting dates within my records. If
    > gives me a type mismatch error is the form field was empty.
    >
    > 2. How will the sql server differentiate that the date coming from UK
    > webserver example "03/01/2005" is 3rd January 2005 and the same date
    > coming
    > from US webserver "03/01/2005" is 1st March 2005. Do I need to deal with
    > this in the ASP code? or maybe I need to convert them to a more generic
    > format. Does anyone know of a fool proof function to convert the dates
    > into
    > universal formats.
    >
    > Thanks in advance for your help.
    >
    > Regards
    >
    >
     
    SP, Aug 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    908
    Rob Schieber
    Sep 30, 2005
  2. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    234
    Mark Schupp
    Aug 9, 2004
  3. Replies:
    1
    Views:
    239
    Jano Svitok
    Jul 17, 2007
  4. kellygreer1

    RFC-822 dates into Ruby dates

    kellygreer1, Jun 8, 2008, in forum: Ruby
    Replies:
    1
    Views:
    262
    Eric I.
    Jun 8, 2008
  5. Dr J R Stockton

    FAQ Dates; Opera Dates.

    Dr J R Stockton, Jun 18, 2007, in forum: Javascript
    Replies:
    0
    Views:
    190
    Dr J R Stockton
    Jun 18, 2007
Loading...

Share This Page