Showing posts with label datetime. Show all posts
Showing posts with label datetime. Show all posts

Friday, March 23, 2012

I want to select the SECOND newest record in a table,....is this possible?

Hi!
I want to do a query against a SQL DB and by sorting a datetime field, I want to get the second newest record in the table, not the newest.
Can I do that?
/Johan Ch

You could do it like this:
SELECT TOP 1
*
FROM
(SELECT TOP 2 * FROM myTable Order by myDateTime DESC) AS A
ORDER BY
myDateTime ASC

Wednesday, March 21, 2012

I want to convert datetime value into MonthName.

In Page Body, there is a textbox whose value is in "mm/dd/yyyy" form. So I want it in "dd MonthName yy" format. How to do it.

Suppose the field name is field1 which has date in dd/mm/yyyy format, use this in the value expression

DatePart("dd", field1) & " " & MonthName(field1) & " " & DatePart("yy", field1)

|||

It's acually even simpler than that.

In the format properties of the textbox enter in the Format Code: box (top left of tab)

dd MMMM yyyy to return a date such as 03 Novermber 2006

or

dd MMM yyyy to return a date such as 03 Nov 2006