473,401 Members | 2,146 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,401 software developers and data experts.

First and Last Day of actual Month

Is there a function to get the first and the last day of the actual month?

Regards
4vTurbo
Dec 15 '11 #1
2 3039
Rabbit
12,516 Expert Mod 8TB
The first day of a month is always the same. For the last day, you can take the first day of the next month and subtract a day.
Dec 15 '11 #2
NeoPa
32,556 Expert Mod 16PB
For the first day you can format a string starting with "1/" (or including "/1/" if American) and converting that to a date, or you can use the Day() and DateAdd() functions to move to the correct date :

Expand|Select|Wrap|Line Numbers
  1. CDate(Format(Date(), "m/1/yyyy"))
  2. DateAdd("d", 1 - Day(Date()), Date())
For the last day you would go back one day from the first of next month :

Expand|Select|Wrap|Line Numbers
  1. DateAdd("d", -1, CDate(Format(DateAdd("m", 1, Date()), "m/1/yyyy")))
Dec 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Solomon Grundy | last post by:
Select trunc(sysdate,'MM') from dual of course gives me the first day of the month, may I ask what the query is to find the first saturday of the month?
2
by: toedipper | last post by:
Hello, PHP and mysql I have the following select statement whch gives me a count for downloads for previous day. SELECT COUNT(swid) FROM
2
by: NotGiven | last post by:
I can get the month of the date selected but not when the claendar control is first opened or when you go to the next or previous month. I'm sure it's simple, thanks for any help!
0
by: bdtmike | last post by:
I'm using the GridView control and have the Mode of the Pager set to "NumericFirstLast". However, when there are several pages to display, the pager shows only page numbers--and no First/Last...
1
by: Frank Bishop | last post by:
I have been spoiled by some report writing tools that have intrinsic functions like Last Year Month-to-date. I'm looking for a way to emulate this in SQL Server now with my fields that are...
2
by: Tony Ciconte | last post by:
Does anyone know of or have any VBA code or similar logic that can help distinguish similar first/last name combinations? For example, we would like to prompt the user of a possible match when any...
10
by: meltedown | last post by:
If I have an sql date, such as "2006-11-19" is there a way using either sql or php date and time functions to get the date of the the first day of the month ?
2
by: Janick Bernet | last post by:
I just stumbled upon this olap function and wondered why the "NULLS FIRST/LAST" clause is not possible in normal order by but only using row_number() over(). Sure, I can do a SELECT *,...
10
by: YvesDM | last post by:
Hi, How can I do this, I've got a little form with a dropdown. <select name="maand"> <option value='1'>januari</option> <option value='2'>februari</option> <option value='3'>maart</option>...
14
by: yappy77 | last post by:
I have a query that I need help in writing the expression to calculate the first of the month following the end of previous month. Example: Policy expiration date = between 2/1/11 and 2/28/11...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.