ASP - MSSQL date format problem

This is a discussion on "ASP - MSSQL date format problem" within the Classic ASP section. This forum, and the thread "ASP - MSSQL date format problem are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 22nd, 2005, 21:17
New Member
Join Date: Nov 2005
Age: 41
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ASP - MSSQL date format problem

Hi
I’m new to MS-SQL and I’m having a problem with an ASP3 JS website that I’m upgrading from Access. I’m trying to format the date from mm/dd/yyyy as held in the db by GETDATE to display as dd/mm/yyyy on a web page.

Previously with the Access db I used -
"SELECT format(addate, 'dd/mm/yyyy') as addate1 FROM...”

What do you use with MS-SQL???

Any help greatly appreciated as this is driving me nuts!!!
Reply With Quote

  #2 (permalink)  
Old Nov 23rd, 2005, 07:57
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Re: ASP - MSSQL date format problem

Code: Select all
CAST()
You'll have to search on google for examples of how to use it cause its been so long i cant remember!
Reply With Quote
  #3 (permalink)  
Old Nov 23rd, 2005, 13:21
New Member
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: ASP - MSSQL date format problem

If you wanted to format the date through ASP you can do that using the 'Format' function. However just like above I cannot remember the exact syntax so google is your best bet for that.

Tim
Web Design
Reply With Quote
  #4 (permalink)  
Old Nov 24th, 2005, 12:26
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Re: ASP - MSSQL date format problem

Quote:
Originally Posted by avalon
If you wanted to format the date through ASP you can do that using the 'Format' function. However just like above I cannot remember the exact syntax so google is your best bet for that.

Tim
Web Design
Code: Select all
FormatDateTime()
Reply With Quote
  #5 (permalink)  
Old Nov 29th, 2005, 12:56
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Re: ASP - MSSQL date format problem

you could try adding to the first line of your query:

SET DATEFORMAT DMY;

This will force the date as dd/mm/yyyy

Might be of help!
Reply With Quote
  #6 (permalink)  
Old Nov 29th, 2005, 23:15
Anonymous User
Guest
Posts: n/a
Re: ASP - MSSQL date format problem

select convert(varchar(10), addate, 103) as 'addate1' from....

Last edited by rrhodes; Dec 10th, 2005 at 23:40.
Reply With Quote
Reply

Tags
asp, mssql, date, format, problem

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
JS date format joe3dge JavaScript Forum 0 May 21st, 2007 00:11
Changing date format in date picker AdRock JavaScript Forum 1 Aug 1st, 2006 17:16
Date/Time format & multiple selection with listbox problem frmsasp ASP.NET Forum 0 Oct 12th, 2005 10:29
date format help please charter Databases 3 Jun 14th, 2004 20:09
Date Format ekendricks Classic ASP 3 Sep 1st, 2003 17:03


All times are GMT. The time now is 23:28.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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