Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2004, 03:24 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date Format - Truncating - Plz Help - THNX !

Hi All,

I think this is an easy question.

I've a date field (pulled from db) that has the time with it:

6/25/1969 12:00:00 AM
12/25/1969 12:00:00 AM

I would like to just extract the mm/dd/yyyy,
so it would look like this:

6/25/1969
12/25/1969

Any ideas? Thanks in advance !
 
Old March 30th, 2004, 08:21 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind, I figured it out.

If you're wondering, you can do it in 2 ways:

in your T-SQL script, use the convert function:
Convert(Char(10),datestring,101)

Or in vb.net, use the following statements:
'strDate returns desire format
    Dim strDate as String
    strDate = String.Format("{0:dd/MM/yyyy}", CType(DtDate, Date))
 
Old March 30th, 2004, 11:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You can also do it in .Net like this:

FormatDateTime([DateToFormat], DateFormat.ShortDate)

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM
Anchor Problem - Plz Help - ThnX ! ank2go HTML Code Clinic 6 June 30th, 2004 03:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.