Solved

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

Posted on 2014-09-16
5
167 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
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 45

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now