Solved

date Format

Posted on 2004-09-26
7
199 Views
Last Modified: 2010-04-23
hi, i use

alarmDate.Value.Month.ToString() and alarmDate.Value.Day.ToString()

but i only get the dates in this format. 1 instead of 01 do you get what i mean? how can i get them in "01" format?
0
Comment
Question by:stromberg10
[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
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12153996
Dim m = lpad(alarmDate.Value.Month.ToString(),2,'0')
Dim d  = lpad(alarmDate.Value.Day.ToString(),2,'0')
0
 

Author Comment

by:stromberg10
ID: 12154003
i got an error
 Dim m = lpad(alarmDate.Value.Month.ToString(),[HERE IT SAYS Expression expexted]2,'0')


I am useing .net framework 2.0 beta. I don't know if that is the problem.
0
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12154064
Try this
Dim m = alarmDate.Value.Month.ToString()
Dim len = m.length
if(len==1)
m="0" & m 'concatenate zero
else
'do nothing

if this works do the same for day value also
0
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!

 

Author Comment

by:stromberg10
ID: 12154152
nope it dosen't work.

there is some errors.

Dim len (Variable declaration without an 'As' clause; type of object assumed
Dim m (Variable declaration without an 'As' clause; type of object assumed
0
 
LVL 4

Accepted Solution

by:
Kaarthick earned 50 total points
ID: 12154160
Dim m as String
Dim len as Integer
m =  alarmDate.Value.Month.ToString()
len = m.length
if(len==1)
m="0" & m 'concatenate zero
else
'do nothing
0
 

Author Comment

by:stromberg10
ID: 12154178
it works now. But if a date ar ex 14 it will be 014 and i don't want it to be so. I change == in the if(len==1) to if (len = 1) because the program gave me an error.  Expression expected on == is that why i get 014 instead of 14 if a number are below 10 the funktion works fine.
0
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12154200
Did you check the code by executing it? coz it will concatenate "0" for the value other than 1 to 9 as the length it becomes more than 1.

As you said == is not the problem i guess.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 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