SOLUTION
Thanks to casper, here is my resulting function:
Shared Function FormatDate(ByVal s As String) As String
Dim DT As DateTime
s = Regex.Replace(s, "[^1234567890]", "")
DT = DateTime.ParseExact(s, "HHmm", Globalization.CultureInfo.InvariantCulture)
Return DT.ToString("h:mm tt")
End Function
Much better :D
I a...
This seems rather simple but it has been giving me a headache. I have a column in my events table that is called 'date_time' and it's type is datetime.
I need to write a query that will get events by day.
Example of table
============================
| id | date_time |
============================
| 5 | 2009-03-27 14:16:00 ...
In my application, I have some records which I need to filter based on some time parameters. To do the date comparisons, I need to convert the dates in my records (a string in the format YYYY-MM-DD), to a unix timestamp (seconds since 1970). Since I have many thousands of records, I really want to find the most efficient way to do it.
A...
I want to save my dates in sql2005 as dates (without hour minutes and seconds).
I want to do this because the between function isn't always correct if the hours, minutes and seconds are filled in.
but neither datetime nor smalldatetime allows this, in 2008 you have the Date column which can do this.
I've also found this question which ...
I have a string of "DD/MM/YYYY HH:MM:SS" which I need to transform to a date, the problem is the default conversion goes "MM/DD/YYYY HH:MM:SS" unless the day is >12 in which case it switches. I'd like to ensure that my day's go into the day portion of the date/time.
Is there an easy fix to this?
...
I need to determine the number of days in a month for a given date in SQL Server.
Is there a built-in function? If not, what should I use as the user-defined function?
...
How can I parse an ISO date string into a date object in Flex (AS3)?
e.g.
2009-12-08T04:23:23Z
2009-12-08T04:23:23.342-04:00
etc...
...
This question is kind of a subset of 90308
I'm looking for a good date library in any language which can handle periodic concepts
Date Ranges/sets which are independent of year:
dr = 1 May - 31 August
(4 May 2010) in dr
true
(4 May 2011) in dr
true
(4 March 2012) in dr
false
Day sets:
ds = m tu w sa su
(Mon, 4 ...
We are creating a unix timestamp with the mktime method giving following attributes:
print_r(mktime(0,0,0,3,1,2009));
print_r(mktime(null,null,null,3,1,2009) / 60 / 60 / 24) . "days");`
this creates a result of
1235862000
14303.958333333 days
this should be 14304 days. The problem in this case is the winter hour.
You can use the i...
Does anyone have a relative date/time from now to a natural/human for classic ASP function in VBScript? This is like Twitter.
Examples:
Less than 1 minute ago
About 5 minutes ago
About an hour ago
About 3 hours ago
Yesterday
Wednesday
etc.
...
In an extract I am dealing with, I have 2 fields. One field stores the dates and another the times as shown.
How can I query the table to combine these two fields into 1 column of type date?
Dates
2009-03-12 00:00:00.000
2009-03-26 00:00:00.000
2009-03-26 00:00:00.000
Times
1899-12-30 12:30:00.000
1899-12-30 10:00:00.000
1899-12-30...
I have a table that stores stock ticks in sql server 2008. It is keyed on the symbol column and the datecolumn which is a datetime2. In a c# app inserts are sent in at a high rate to the table. Currently a row is made using the symbol and DateTime.Now and then inserted. Occationaly the situation can arise where 2 ticks for the same s...
In Python, I'm attempting to retrieve the date/time that is exactly 30 days (30*24hrs) into the past. At present, I'm simply doing:
>>> import datetime
>>> start_date = datetime.date.today() + datetime.timedelta(-30)
Which returns a datetime object, but with no time data:
>>> start_date.year
2009
>>> start_date.hour
Traceback (most r...
I need to store dates in SharePoint that need to go back around 5000 BC. Ideally, I would like to be able to do date addition/subtraction, like this:
oldDate = '5000 BC';
newDate = '1995 AD';
DateDiff(oldDate, newDate, 'Years'); // equals 6995
How should I proceed? Build an old_date class based on strings? Just use regular dates, b...
How can I add the current date and time (the date and time set on the server) to a MySQL table?
...
Consider the following TSQL:
SET @WhereClause1 = 'where a.Date > ' + @InvoiceDate
I get a date/string conversion error. @InvoiceDate is a datetime variable. What is the right syntax?
...
Across various SQL dialects, what string representation for a Date and/or DateTime would be most likely to be interpreted correctly? Is there an SQL Standard? Are the two answers identical or similar?
EDIT:
For suggestions, can we all please comment with any known SQL dialects that don't comply?
...
Hi,
i am trying to build a gui that includes editing a DateTime value of an object. The DateTime Property has binding to a DataPicker and a normal TextBox for the Time.
When i change the value in the Time TextBox the value wirtten in the DateTime Property is Today with the entered Time instead of just updating the Time, preserving the...
Why does the ToUniversalTime function have no effect here;
DateTime dt = new DateTime(2009,3,24,1,0,0,DateTimeKind.Local);
dt = dt.ToUniversalTime(); // convert BST to UTC ?
dt.ToString();
"24/03/2009 01:00:00" ... wrong?
Is the same as..
DateTime dt = new DateTime(2009,3,24,1,0,0,DateTimeKind.Utc);
dt = dt.ToUniversalTime(); // not...
I'm using Webdatechooser<<Infragistics control>> for a column which takes the datetime.
I need to convert the value entered (through the Webdatechooser) to dd-mmm-format.
Can I have snippets for that?
...