473,385 Members | 1,958 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,385 software developers and data experts.

Get dateformat in yyyymm

If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot
--
..
Nov 21 '05 #1
5 2817
Dim d As DateTime = "2004-02-05"

MessageBox.Show(d.Year.ToString("0000") & d.Month.ToString("00"))


--
Scott Swigart
http://blog.swigartconsulting.com

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:e2****************@tk2msftngp13.phx.gbl...
If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot
--
.

Nov 21 '05 #2
"Agnes" <ag***@dynamictech.com.hk> schrieb:
If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot


\\\
MsgBox( _
Date.ParseExact( _
"2004-02-05", _
"yyyy-MM-dd", _
Nothing _
).ToString("yyyyMM") _
)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Agnes

MyResultString = MyOriginalString.substring(0,4) &
MyOriginalString.substring(5,2)

I hope this helps?

Cor

"Agnes"
If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot
--
.

Nov 21 '05 #4
Agnes wrote:
If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot


To add another possible solution:

Dim d As DateTime = DateTime.Parse("2004-02-05")
MessageBox.Show(Format(d, "yyyyMM"))

--

(O)enone

Nov 21 '05 #5
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:e2****************@tk2msftngp13.phx.gbl...
If my input date is 2004-02-05, I want to get '200402'
Can anyone know the simple way to do ? Thanks a lot


Dim dtThen as DateTime _
= CDate( "2004-02-05" )

Console.Writeline( dtThen.ToString("yyyyMM") )
' NB: That's "MM", not "mm"

HTH,
Phill W.
Nov 21 '05 #6

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

Similar topics

0
by: Phil | last post by:
My regional setting (on Win2000) is: (General Tab)Locale = English (US) (Date Tab), short date = MM/dd/yy When I ask .Net DateFormat.ShortDatePattern, I get MM/dd/yyyy Now, where does the...
2
by: Grant Merwitz | last post by:
Hi I have installed my web app on a Windows 2003 server. The Regional and Language was originally set to American. Now we have changed it to UK, and are trying to get the DateFormat right. ...
3
by: Agnes | last post by:
In my old vfp application, there is DTOS function to return 'yyyymm' ,in .net any similar function ?? DTOS(datetime.now) and return yyyymm, I know that I can CType(Year(datetime.now), String) &...
4
by: newtophp2000 | last post by:
Hello, I receive a file containing some character fields along with a date. The date values in the file are formatted as "dd/mm/yy", that is 2-digit day, 2-digit month, and 2-digit year. The...
1
by: Zack Lau | last post by:
Is it any function that can convert a string yyyymm to da date format? :confused:
0
by: pankajol82 | last post by:
Hi all I am using following code to change regional setting at run time its not giving any error but at the same time the format of date is not changing. Dim DateFormat As New...
2
by: piotr.kabath | last post by:
Hi I have date stored as number in yyyymm format, as I need to calculate previous month\ prev 3 months etc, I need to convert this to date format yyyymm. I have tried but with no success, I would...
1
zigman68
by: zigman68 | last post by:
I have a problem with the DateFormat() Function that is driving me nuts! I am downloading a csv and then parsing through it, then inserting into a SQL 2005 DB. Here is the problem. ... A number of...
3
dzenanz
by: dzenanz | last post by:
String input="4/3/08 9:57 AM"; DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); StartDate = df.parse(input); out.println(StartDate.toLocaleString());//"Apr 3, 2008 12:00:00 AM" ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.