1,105,406 Community Members

Simple Code for Getting Current Date and Time

Member Avatar
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

Just a quick snippet for beginners

Public Shared Function getCurrentDateTimeString() As String ' Returns current date and time in this format: "yyyyMMddHHmmssff"         Dim rightNow As DateTime = DateTime.Now         Dim strCurrentDateTimeString As String         strCurrentDateTimeString = rightNow.ToString("yyyyMMddHHmmssff")         Return (strCurrentDateTimeString)     End FunctionPublic Shared Function getCurrentDateTimeString() As String ' Returns current date and time in this format: "yyyyMMddHHmmssff"

        Dim rightNow As DateTime = DateTime.Now

        Dim strCurrentDateTimeString As String

        strCurrentDateTimeString = rightNow.ToString("yyyyMMddHHmmssff")

        Return (strCurrentDateTimeString)

    End Function
Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 
Member Avatar
Momerath
Senior Poster
3,830 posts since Aug 2010
Reputation Points: 1,327 [?]
Q&As Helped to Solve: 664 [?]
Skill Endorsements: 19 [?]
Featured
 
0
 

Why go through all the variable manipulation:

Public Shared Function getCurrentDateTimeString() As String ' Returns current date and time in this format: "yyyyMMddHHmmssff"
    return DateTime.Now.ToString("yyyyMMddHHmmssff"
End Function
Member Avatar
JJCollins
Junior Poster in Training
67 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

I like to do things the long way for beginners, the code is simple but there is more of it, just feel you'll learn more about the language, syntax etc from 6 lines of code rather than 3, personal preference i guess :)

- Jordan

Member Avatar
bossie09
Light Poster
31 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Any one here can help me with a programming assignment....... C, C++ or Java language, anyone, WE can negotiate a price.

Member Avatar
JJCollins
Junior Poster in Training
67 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]
 
0
 

This is the wrong forum for C / C++ / Java my friend, a post in the appropriate forum would be better for you

- Jordan

Member Avatar
Wel Da gr8
Newbie Poster
1 post since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

I need a code to show only the previous month date i.e. the program executes this month but must show last months date or just a month. So there's a message that says "attached is the monthly report", instead of saying 'monthly' report, it must print the last month's name 'month' e.g. 'Feb', 'Mar' etc ...

Thnx
W.

You
Post:
Start New Discussion
View similar articles that have also been tagged: