Solved

Format SYSTEM.DATETIME.NOW

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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