SunQuest
 
           General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 21st, 2005, 10:33 AM
Maeka Maeka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 Maeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face Pulling out only the date from the datetime field

I am totally new to the SQL Develpment world. i am trying to find a way to extract on the date from a date time field. In the SQL datebase column name= [date] data type= datetime length=8.

On my asp page I have it calling in field. And then i have displayed it by <&k_date&>.

Please help

Thanks

Reply With Quote
  #2  
Old August 3rd, 2005, 08:47 AM
jalbersdorfer jalbersdorfer is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Location: in Germany, Bavaria
Posts: 5 jalbersdorfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 41 sec
Reputation Power: 0
in MSSQL you can write the following:
Code:
select convert (varchar, YourColumn, 104) from table

the 104 according to the following table: (I know it's hardly readable, because I copied out of a Help-File)
Quote:
Without century (yy) With century (yyyy)
Standard
Input/Output**
- 0 or 100 (*) Default mon dd yyyy hh:miAM (or PM)
1 101 USA mm/dd/yy
2 102 ANSI yy.mm.dd
3 103 British/French dd/mm/yy
4 104 German dd.mm.yy
5 105 Italian dd-mm-yy
6 106 - dd mon yy
7 107 - Mon dd, yy
8 108 - hh:mm:ss
- 9 or 109 (*) Default + milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM)
10 110 USA mm-dd-yy
11 111 JAPAN yy/mm/dd
12 112 ISO yymmdd
- 13 or 113 (*) Europe default + milliseconds dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 or 120 (*) ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
- 21 or 121 (*) ODBC canonical (with milliseconds) yyyy-mm-dd hh:mi:ss.mmm(24h)
- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(no spaces)
- 130* Kuwaiti dd mon yyyy hh:mi:ss:mmmAM
- 131* Kuwaiti dd/mm/yy hh:mi:ss:mmmAM

Reply With Quote
  #3  
Old May 22nd, 2006, 03:10 AM
mail2radhikaraj mail2radhikaraj is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 4 mail2radhikaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 12 m 4 sec
Reputation Power: 0
Thumbs up to extract date,hr,yr.......seconds from a datetime field

Quote:
Originally Posted by Maeka
I am totally new to the SQL Develpment world. i am trying to find a way to extract on the date from a date time field. In the SQL datebase column name= [date] data type= datetime length=8.

On my asp page I have it calling in field. And then i have displayed it by <&k_date&>.

Please help

Thanks



you can use an inbuilt function in sql called 'datepart' which takes 2 parameters ......the part u want to extract and the column name


eg.

select datepart(dd,getdate() ) from temp

this will give you the date of present day.

similarly u can use 'yy','hh','mi','s' and 'mm' to find to get year,hour,minutes,seconds resp

hope this helps ya.....

regards,

Radhika.

eg

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Pulling out only the date from the datetime field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway