Solved

Format SYSTEM.DATETIME.NOW

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

21 Experts available now in Live!

Get 1:1 Help Now