473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DateString convert

I would like to get the string in this format: yyyyddmm , like in sql.

I read the date from the calendarControl:

dateString=Calendar.SelectedDate.Date.ToShortDateS tring

and I get dateString=4.12.2003

I would like to have:dateString=12042003

What is the best way to do that?

Thank you,

Simon


Nov 20 '05 #1
5 1729
Try the following code: y=year, M=month, d=day

Dim strDate as String = Format(DateTime.Now, "yyyyMMdd")
Nov 20 '05 #2
"simon" <si*********@stud-moderna.si> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I would like to get the string in this format: yyyyddmm , like in sql.
SQL does not have a date format.
It can apply formatting to values as they are returned to you but,
internally, the database can store the data any way it darn well
pleases (and it'll be nothing like anything you or I can make sense
of).
I read the date from the calendarControl:
dateString=Calendar.SelectedDate.Date.ToShortDateS tring
and I get dateString=4.12.2003


which is exactly what you asked for.

If you want a /specific/ format, then format the Date the way
you want it to be, as in

dateString = Calendar.SelectedDate.Date.ToString( "ddMMyyyy" )

Bear in mind that VB will have a Devil of time trying to turn this
eight-digit number back into a Date, if you ever ask it to...

HTH,
Phill W.
Nov 20 '05 #3
* "simon" <si*********@stud-moderna.si> scripsit:
I would like to get the string in this format: yyyyddmm , like in sql.

I read the date from the calendarControl:

dateString=Calendar.SelectedDate.Date.ToShortDateS tring


'<...>.Date.ToString(<format>)'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
"simon" <si*********@stud-moderna.si> schrieb
I would like to get the string in this format: yyyyddmm , like in
sql.

I read the date from the calendarControl:

dateString=Calendar.SelectedDate.Date.ToShortDateS tring

and I get dateString=4.12.2003

I would like to have:dateString=12042003

What is the best way to do that?


Use the Date's ToString method instead of ToShortDateString. You can pass
the needed format to ToString.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
>> YYYYMMDD
Bear in mind that VB will have a Devil of time trying to turn this
eight-digit number back into a Date, if you ever ask it to...


Microsoft.VisualBasic.DateAndTime.DateSerial()

Although, that's not really the ".NET Way".
--
Peace & happy computing,

Mike Labosh, MCSD
Owner, vbSensei.Com
"Escriba coda ergo sum." -- vbSensei
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.