Solved

date Format

Posted on 2004-09-26
7
194 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

13 Experts available now in Live!

Get 1:1 Help Now