Solved

Format SYSTEM.DATETIME.NOW

Posted on 2006-11-02
4
5,872 Views
Last Modified: 2008-03-17
I have the below SQL Insert statement in my WinApp and I would like to make the formatting (mm/dd/yyyy) instead of the default mm/dd/yyy hh:mm

I am trying to do this an easy way without having to create a declaration first, because i know I can do it like so:

        Dim strdate As DateTime
        strdate = System.DateTime.Now
        Dim displayString As String
        displayString = Format(strdate, "MM/dd/yyyy")

\\\\\\\\\\\\\\\INSERT STATEMENT\\\\\\\\\\\\\


        strSQLInsert = strSQLInsert & "'" & Trim(System.DateTime.Now) & "',"
0
Comment
Question by:chrisryhal
4 Comments
 
LVL 10

Assisted Solution

by:Kinger247
Kinger247 earned 100 total points
ID: 17860395
Try : convert(varchar(10), convert(datetime, getdate(), 103), 103)
0
 
LVL 7

Assisted Solution

by:rvidal393
rvidal393 earned 100 total points
ID: 17860400
try this, it will give you a date formated like "1/1/2006"

strSQLInsert = strSQLInsert & "'" & System.DateTime.Now.ToShortDateString  & "',"
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 300 total points
ID: 17860495
You can also use ToString() to format the DateTime however you want:

    strSQLInsert = strSQLInsert & "'" & System.DateTime.Now.ToString("MM/dd/yyyy") & "',"
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 17929516
They all worked, but I actually am using Idle_Minds.  I am going to award everyone points though.  Thanks for the help!!!!  I get confused sometimes when messing around with formats.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

15 Experts available now in Live!

Get 1:1 Help Now