Solved

changing format of getdate to include yyy-mon-....

Posted on 2014-09-16
5
173 Views
Last Modified: 2014-09-16
how can you change the normal getdate() to the a format like:
2014Aug1808301403394

specifically, how to change 08 to Aug like in the above example and how to more precision beyond millisecond?

this is for sql 2012

thanks
0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 167 total points
ID: 40325361
1. To get "Aug", you should use:

select left(datename(mm,getdate()),3)

2. To get more milliseconds, instead of using Getdate(), you should use:

select sysdatetime()
0
 
LVL 51

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 166 total points
ID: 40325365
It is this that you want?
SELECT CONVERT(VARCHAR, GETDATE(), 109)

Open in new window

0
 
LVL 21

Accepted Solution

by:
Randy Poole earned 167 total points
ID: 40325372
Select format(getdate(),'yyyy MMM dd HH mm ss FFFFFFF')

Open in new window

This will also give you up to 6 digits 3 for milliseconds and 3 for macroseconds
0
 
LVL 5

Author Comment

by:25112
ID: 40325421
thanks - we are getting close.
 
    Select format(sysdatetime() ,'yyyy MMM dd HH mm ss FFFFFFF')
  Select format(GETDATE() ,'yyyy MMM dd HH mm ss FFFFFFF')
  gives
2014 Sep 16 09 46 43 7699724
2014 Sep 16 09 46 43 767 (4 precision less than the above)

what we need is ( without the 2 extra digits with sysdatetime)
2014 Sep 16 09 46 43 767__
0
 
LVL 5

Author Comment

by:25112
ID: 40325478
sorry- I do see it now.


   Select format(sysdatetime() ,'yyyy MMM dd HH mm ss FFFFF')

thanks all.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question