Jump to content
Sign in to follow this  
ciqeane

Datetime Kepada Date

Recommended Posts

Saya baru dalam MSSQL ni.
Sori nak tanya soalan sikit.
Saya nak tahu adakah ada function that will return only the date from a DateTime field?

Thanks.

Share this post


Link to post
Share on other sites
yeah dah dapat convert from datetime to date.


macam ni

[code]CONVERT(VARCHAR,column_date, 101)[/code]

dapat answer ni dari SteveSmithBlog.com

[quote]
Get Date From DateTime In SQL
Something I need to do from time to time is get just the date part of a datetime value in SQL. I found a cool way to do it on SQLJunkies today.

select convert(varchar,DateColumn,101)

The 101 means “mm/dd/yyyy” format, but there are a bunch of other codes you can use. 108 will return just the time “hh:mm:ss” for instance.

Update: 101 includes 4 digit year 'yyyy'. A code of 1 would apparently be "mm/dd/yy", according to user comments. Thanks![/quote] Edited by TOYSЯUS
code and quote :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...