Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date format (leading zeros)

Status
Not open for further replies.

endoflux

Technical User
Aug 6, 2001
227
0
0
US
I've got a form which requires date entry by a user. The value entered is checked on the 'post' page to ensure its a valid date. The format entered is always MM/DD/YYYY, including a leading 0 when the month is <10 (IE 06/01/2007). This works great...

...then I also have a form for the user to update this information. When the date is pulled back out of the SQL DB, the date format has dropped the leading zeros (IE 6/1/2007). In my current code, the user has to put the zeros back in before submitting any other changes, or my format check will reject the date format.

So my question: any way to force a specific date format with leading zeros into the SQL db?

Thanks!
 
Dates are stored as numbers, the format is up to you.
 
Yeah, but by default it's returning 6/1/2007...is there any way to change this default in the SQL server config?
 
Check out "CAST and CONVERT" in SQL Server BOL. Also maybe try posting in the "Microsoft SQL Server: Programming" forum if you are looking for a SQL Server solution. An Access solution would be to use the format function when extracting the data from SQL Server.
Good Luck!

Silence is golden.
Duct tape is silver.
 
This is the Jet SQL forum. I can tell you what to do in Access, for SQL Server you want an SQL forum, say forum183.

If you have an Access front end, I suggest you set the format of the control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top