Solved

Format SYSTEM.DATETIME.NOW

Posted on 2006-11-02
4
5,885 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
[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
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 86

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
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.…

617 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