The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Tip on Datetime and SQL

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Paschal

Posts: 1621
Nickname: bigapple
Registered: Nov, 2003

Paschal is a .Net developer
Tip on Datetime and SQL Posted: May 28, 2004 12:05 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Paschal.
Original Post: Tip on Datetime and SQL
Feed Title: help.net
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/pleloup/Rss.aspx
Feed Description: .Net for mankind !
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Paschal
Latest Posts From help.net

Advertisement

A lot of non-US developers have troubles with date andling and SQL Server.

If you send to SQL 01/10/2003 it could be interpreted as October 1 2003 or January 10 2003 depend where you live.

I don't find .Net so easy on this subject. So this what I do to send the right format to SQL, and it will be interpreted correctly whatever the settings you have.

This is based on the fact that SQL accept a date like this '20041001' (YYYYMMDD format) . So whatever your settings, this will be all the time seen as October 1st 2004.

If you need to send your date as a parameter for a stored procedure, you must transform your date like this (VB code):

MyDateParameter = CStr(MyDate.Date.GetDateTimeFormats("d")(4).Replace("-", "")))

The method GetDateTimeFormats returns an array of all posible date formats. So here I choose the 4th element returning a date as 2004-10-01 and I just remove the '-' character.

I tried different options, and I didn't found the exact SQL format like '20041001', that's why I choose this option.

 

 

Read: Tip on Datetime and SQL

Topic: UK event: Web Content Management & tour of the Subaru World Rally Team HQ. Previous Topic   Next Topic Topic: UK Breakfast Briefing: Enterprise Content Management For Financial Services - How RSS can play a...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use