Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dates in SQL Server

Reply
Thread Tools

Dates in SQL Server

 
 
JP SIngh
Guest
Posts: n/a
 
      08-02-2005
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


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-02-2005
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.


 
Reply With Quote
 
 
 
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      08-02-2005
> 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


 
Reply With Quote
 
SP
Guest
Posts: n/a
 
      08-04-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RFC-822 dates into Ruby dates kellygreer1 Ruby 1 06-08-2008 10:59 PM
Need to use dates earlier than 1900 (Time library says out of range for dates < 1900) me@benjaminarai.com Ruby 1 07-17-2007 02:25 PM
FAQ Dates; Opera Dates. Dr J R Stockton Javascript 0 06-18-2007 03:51 PM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM



Advertisments