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

Formatting numeric values as dates?

I'm having problems getting dates to format the way that I need them to. The
problem is that I'm used to the VB6 way of doing things, with which the
statement Format(37866, "dd MMM yyyy") would yield the string "02 Sep 2003".
If I run the same thing in dotNet, it gives me back the format string, which
isn't very useful.

It *does* work If I convert the value to a date beforehand, but
unfortunately that doesn't help me because I don't know what values are
dates, and what values are other types of numbers at the point where I
actually need to do the formatting.

So the question is, is there a way to format my numeric value as a date
without first converting it into a date? I've been at this for a while and
I'm at a loss...

Thanks in advance,
- Steve
Nov 20 '05 #1
3 3981
Hi Steve,

The bad news is that if <you> don't know whether you've got a date or just
a number, VB.NET <certainly> won't know. And VB.NET doesn't like not knowing
what it's dealing with. Very cagey it is about that sort of thing.

So the question has to be turned around and become how do you determine
what you've got so that you <can> convert into date format?

I'm curious. How do you get to your Format (SomeNumber, "dd MMM yyyy")
without knowing what your dealing with ? And what would your VB6 app do with
the result?

Regards,
Fergus
Nov 20 '05 #2
Cor
Steve,
I'm try too learn more of the English language.
I somethimes hear the sentences "Blind dates", is that this?
Cor
Nov 20 '05 #3
Well, VB6 can figure it out just fine from the format string. <It> knows how
to parse the format string and it <certainly> can recognize a date format
string, and it will recognize that the value is a number that can then be
converted into a date. I know VB.NET isn't VB6, but its supposed to be
BETTER, not worse.

As to your question, I don't literally call Format with some number and a
hard-coded date format string. If I did that then it would be rather obvious
to be that it was a date and I could convert it accordingly. I actually get
a list of values (actually as strings) and a list of format strings from
somewhere and I need to format the numbers according to those format strings
that I was given. Unfortunately, even if I <do> figure out whether or not is
a date, it may be in one of the string formats, or as a number. I was just
trying to simplify my question by skipping the parts about how I get the
values, which are not relevant to the actual question.

Thanks for your help anyway. I'd already decided that it can't do what I
need, I was just seeking other opinions. You never know if someone has
already figured it out.

As an aside, its this kind of stuff that makes VB.NET a pain in the ass. Its
so superior to VB6 in so many ways that it saves gobs of time, but then I
spend weeks on end sorting out the stuff that was trivial in VB6. Without
going into those problems, lets just say I didn't spent <that> much time on
this issue.

- Steve
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Hi Steve,

The bad news is that if <you> don't know whether you've got a date or just a number, VB.NET <certainly> won't know. And VB.NET doesn't like not knowing what it's dealing with. Very cagey it is about that sort of thing.

So the question has to be turned around and become how do you determine what you've got so that you <can> convert into date format?

I'm curious. How do you get to your Format (SomeNumber, "dd MMM yyyy")
without knowing what your dealing with ? And what would your VB6 app do with the result?

Regards,
Fergus

Nov 20 '05 #4

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

Similar topics

163
by: Shiperton Henethe | last post by:
Hi Know any good utilities to help me strip out the tags that Microsoft Excel 2002 leaved behind when you try and export an HTML format file? This is driving me NUTS. And really makes me...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
3
by: success_ny | last post by:
Does anyone have a code snippet to compare those values so I can sort the array of alpha-numeric values that include both characters and integers in it? I.e., if we have values like 4236 and...
4
by: Dave Brydon | last post by:
Access 2003 I have a combo box in my personnel table, which draws its data from a trade code table; the original field in the code table, is numeric, Long Integer, and formatted with 5 zero's . ...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
7
by: Volodymyr Lozovoy | last post by:
Hi All, who suggest why subj do not affect on displayed result for date?
1
by: shearichard | last post by:
Hi - I have written some python to insert a row into a table using MySQLDB. I have never before written SQL/Python using embedded parameters in the SQL and I'm having some difficulties. Could...
7
by: Middletree | last post by:
I am trying to display dates in a spreadsheet, but the dates need to be in a format that will allow them to be sorted in Excel. The datatype in the SQL Server database is datetime. In this case, I...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.