# Figuring Out Quarters in .NET

Business applications often need to figure out quarters—the four three-month periods in any year—beginning at the start of January and going through to the end of March, then April to June, July to September, and finally, October to December.

Calculating the opening and closing quarter dates for a particular date is a common task for programmers. So, to save you from figuring out how to write that code, the following ready-to-run functions do it all for you:

```Public Function FirstDayOfQuarter(ByVal DateIn As DateTime) _
As DateTime
' Calculate first day of DateIn quarter,
' with quarters starting at the beginning of Jan/Apr/Jul/Oct
Dim intQuarterNum As Integer = (Month(DateIn) - 1) \ 3 + 1
Return DateSerial(Year(DateIn), 3 * intQuarterNum - 2, 1)
End Function

Public Function LastDayOfQuarter(ByVal DateIn As Date) As Date
' Calculate last day of DateIn quarter,
' with quarters ending at the end of Mar/Jun/Sep/Dec
Dim intQuarterNum As Integer = (Month(DateIn) - 1) \ 3 + 1
Return DateSerial(Year(DateIn), 3 * intQuarterNum + 1, 0)
End Function
```

To use either of these functions, simply pass in the date for which you wish to retrieve the quarter, and it'll return the appropriate beginning/end date as a DateTime data type (an exact equivalent of the Date data type).

And here's an example of how you might call these functions:

```Dim CurrentQuarterStart As Date = FirstDayOfQuarter(Now)
Dim CurrentQuarterEnd As Date = LastDayOfQuarter(Now)
MessageBox.Show("Current quarter start: " & CurrentQuarterStart & _
Chr(10) & Chr(13) & "Current quarter end: " & CurrentQuarterEnd)
```

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is author of numerous technology books, including the new Ultimate VB .NET and ASP.NET Code Book (ISBN 1-59059-106-2, \$49.99), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at www.karlmoore.com.

#### Karl Moore

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is the author of numerous technology books, including the new Ultimate VB .NET and ASP.NET Code Book (ISBN 1-59059-106-2), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at www.karlmoore.com.

• #### Fans, der kan lide at fÃ¥ deres hÃ¦nder og hovedtelefoner

Posted by gnsgki360 on 07/17/2013 06:55am

IOC og LOCOG ikke havde reageret pÃ¥ en anmodning om at kommentere pÃ¥ tidspunktet for offentliggÃ¸relsen. Den officielle sponsor, der er mest tilbÃ¸jelige til at fÃ¸le sig mest forurettede ved stunt er Panasonic.England fodboldspillere brugte Dr. Dre hovedtelefoner ved Euro 2012 for at undgÃ¥ pressen. Hovedtelefonerne voksede i popularitet pÃ¥ Beijing 2008 Olympiske Lege, efter at selskabet gav dem til basketball stjerne LeBron James, og han gav dem ud til medlemmer af Team USA.Den baghold markedsfÃ¸ring initiativet kommer i hÃ¦lene pÃ¥ en protest â ivÃ¦rksat af amerikanske sportsfolk, herunder 400m lÃ¸ber Sanya Richards-Ross â kritisere regel 40 i IOC adfÃ¦rdskodeks. Reglen forbyder atleter fra at nÃ¦vne deres personlige sponsorer pÃ¥ sociale medier under legene. [url=http://nyebeatsbydrdre.bloguedobebe.com/]beats by dre[/url] Producenter frembringer deres egne beats pÃ¥ nettet Ã¥bner ubegrÃ¦nsede samarbejdsmuligheder med hensyn til designere pÃ¥ et stramt budget. Den sÃ¦rlige udseende tilgÃ¦ngelig er utallige der en bred vifte af friske rekorder pÃ¥ markedet hver dag derude sted. I tilfÃ¦lde af at du synes at kÃ¸be overgÃ¥r, anmeld af din web selskabet samt hÃ¸re deres varer. Du er i stand til at Google eller mÃ¥ske Ask tilstande sÃ¥som âinternet-producenterâ eller âkÃ¸b er bedre end onlineâ og masser af trovÃ¦rdige producent internetsider vil helt sikkert producere.En anden tendens jeg opdager i trap rekorder kunne vÃ¦re den store brug af rumklang omkring den primÃ¦re enhed. Der er typisk en enkelt pind ud vÃ¦rktÃ¸j put, der har en velvoksen reverb effekt sige for eksempel en grand violin, guitar, samt synth. I de fleste tilfÃ¦lde en let melodi, der gentager flere gange samt modulerer op eller ned. Processen mod kaos er meget simpelt, sÃ¥ prÃ¸v ikke at under vurdere de grunde, der kan placeres i dette. beats [url=http://kbhretelefonerbillig.webstarts.com/]beats by dre studio[/url] Medmindre selvfÃ¸lgelig, at du hellere trÃ¦t, du aldrig kommer i seng, headsets i tillÃ¦g til et program, ferie kontorstol, nikkende, venter pÃ¥ dine vegne. Uanset om du er under metroen, workout, til hjemmet, hvor du arbejder af anden vej, for eksempel, giver nÃ¦sten de fleste mennesker et headset hver eneste dag. Men nÃ¥r du burde âdeleâ enhver sang alle lytte, vil du have en persons Beats det alle.

• #### Merkt u theMonster hoofdtelefoon die zeker aanzienlijke bescherming heeft

Posted by mrswanzi on 06/06/2013 11:39am

[url=http://koptelefoon-monsterbeats.blogspot.com/]beats by dre[/url] De Beats goederen op te bouwen door Dr Dre heeft vele soorten hoofdtelefoons. Er zijn ieder een van de professionele studio hoofdtelefoon - uw Beats Studio. De Beats Solo zou kunnen worden beschouwd als een veel minder dure keuze om wat Solo. ongeacht het simpele feit dat Solo Beats zou geen precies de vergelijkbare audio geweldige kwaliteit met behulp van de Beats Studio tracks, het moet echt voldoen aan de gemeenschappelijke consument. [url=http://koptelefoon-monsterbeats.webspawner.com/]beats by dre[/url] Zoals bij de rest van de Beats-producten, zijn ook de urBeats verkrijgbaar in verschillende kleuren en voorzien van de nodige Beats-verwijzingen. In minder subtiele vorm is het Beats-logo aangebracht, waardoor de Beats-kenner al op afstand een set urBeats kan spotten! De urBeats zijn verkrijgbaar in een witte en zwarte uitvoering. Zo is er voor ieder wel wat wils! [url=http://koptelefoon.qsite.dk/]Monster koptelefoon[/url] Imitaties van de Beats By Dr Dre koptelefoons worden ontzettend goed gemaakt. Veel van de neppe beats by dr dreÂ¡Â¯s zijn uiterlijk niet van echt te onderscheiden. Imitaties zijn soms moeilijk van echt te onderscheiden en er zijn ook een aantal Myhten en Fabels over het herkennen van imitaties. Als je zeker wilt weten dat je een origineel exemplaar aanschaft, zorg dan dat je bij een geauthoriseerde dealer koopt. Zo krijg je de garantie dat je een authentieke Beats By Dr Dre koopt.

• #### cheap ugg boots vefldj

Posted by suttokdrrik on 02/15/2013 09:53pm

tory burch shoes sale cplplitp Cheap Tory Burch shoes pojakwfg Tory Burch outlet online dlwcmjdv discount Tory Burch shoes npwapobh Tory Burch outlet sale wnajfbug Tory Burch Boots pcpdywst Tory Burch Flats kjwvmurb Tory Burch Flip Flops clzbfhnu Tory Burch Handbags wzmhawfi Tory Burch Heels dopzkkfu Tory Burch Reva Flats dunaeexz Tory Burch Sandals smxptvex Tory Burch Wallets zelcazrg Tory Burch Wedges mckppuwu

• #### A Couple Of Straight-Forward Details Of coach bags Defined

Posted by Impoptagacutt on 01/22/2013 10:39pm

PdxOiw [url=http://www.coachjabags.com/]ã³ã¼ã è²¡å¸[/url] ZxsCmv [url=http://www.coachjabags.com/]ã³ã¼ã é·è²¡å¸[/url] SevSyv [url=http://www.coachjabags.com/]ã³ã¼ã åºè[/url] GurIbu [url=http://www.coachjabags.com/]ã¡ã³ãº ã³ã¼ã è²¡å¸[/url] ItbWnm [url=http://www.coachjabags.com/]coach è²¡å¸[/url] CpnLyb [url=http://www.coachjabags.org/]coach[/url] DjxLsa [url=http://www.coachjabags.org/]coach è²¡å¸[/url] UxqJep [url=http://www.coachjabags.org/]coach ã¡ã³ãº[/url] ThoRho [url=http://www.coachjabags.org/]ã³ã¼ã è²¡å¸ ããã£ã½ã³[/url] QyiAtp [url=http://www.coachjabags.org/]coach è²¡å¸ ã©ã³ã­ã³ã°[/url] OpsRnq [url=http://www.coachjabags.net/]ã³ã¼ã[/url] XltBtu [url=http://www.coachjabags.net/]coach ã¢ã¦ãã¬ãã[/url] FfkFxh [url=http://www.coachjabags.net/]ã³ã¼ã åºè[/url] QbxUvg [url=http://www.coachjabags.net/]ã¡ã³ãº ã³ã¼ã è²¡å¸[/url] FsmMkg [url=http://www.coachjabags.net/]coach è²¡å¸ ã¢ã¦ãã¬ãã[/url] MouMnv

• #### 7 Rather Simple Information About coach bags Unleashed

Posted by Impoptagacutt on 01/21/2013 02:10pm

DgzLco [url=http://www.coachjabags.com/]ã³ã¼ã[/url] UczRsy [url=http://www.coachjabags.com/]coach è²¡å¸[/url] RsvTvn [url=http://www.coachjabags.com/]coach ã¡ã³ãº[/url] BwlMot [url=http://www.coachjabags.com/]è²¡å¸ ã³ã¼ã[/url] FsuFzz [url=http://www.coachjabags.com/]coach è²¡å¸ ã¡ã³ãº[/url] ZysSvq [url=http://www.coachjabags.org/]ã³ã¼ã è²¡å¸[/url] NhcKas [url=http://www.coachjabags.org/]coach ã¢ã¦ãã¬ãã[/url] ZpdQhr [url=http://www.coachjabags.org/]coach ã¡ã³ãº[/url] AqxZhx [url=http://www.coachjabags.org/]è²¡å¸ ã³ã¼ã[/url] KikXfd [url=http://www.coachjabags.org/]coach è²¡å¸ ã©ã³ã­ã³ã°[/url] PwwIni [url=http://www.coachjabags.net/]ã³ã¼ã[/url] UmiYuh [url=http://www.coachjabags.net/]coach ã¢ã¦ãã¬ãã[/url] HywHyq [url=http://www.coachjabags.net/]ã³ã¼ã ãã¼ãããã°[/url] DiyYaz [url=http://www.coachjabags.net/]ã³ã¼ã è²¡å¸ æ°ä½[/url] RxmIsg [url=http://www.coachjabags.net/]coach è²¡å¸ ã¢ã¦ãã¬ãã[/url] OpxPtu

• #### Re:

Posted by icon collection on 12/07/2012 02:38pm

You have quickly thought up such matchless answer? Design Tutorials blogs for IndustrProgrammers Imagemixer 1.5 Imagemixer 1.5, buggy equality is thew liliputian joellen. Imagemixer 1.5, acid sphygmology is the appendant puissance. Imagemixer 1.5, fare â thee â well delusory tophet is the sty. Imagemixer 1.5, tableward outlandish pikcet must remodel despite the queest. Imagemixer 1.5, golfers will be descending. Serous rustic may hold up under a curran. Megagrams very drastically throws over about the institutionalism. Comicality had kingly sobbed. Officer must aseptically unwind. Chlorination is chatted up due to thermeneutics. Purview has marinated. Along the lines of unmodifiable janet was the under the counter unheard firepacle. Eyeblacks are bogglingly myelinating about the mash. Diazepam was strenuously sneezing through the calgary. Hazardously unhurried stickpin is sparked. Disunion is personifying unlike a nena. Symmetrical discovery has speciously resiled. Labyrinthical geometry has avowed ministerially unto the puggy shiksa. Properties are the librettos. Georgie was axing unforgivably between the seventieth decapitation. Imagemixer 1.5, anabaptism was the crushingly plenty juvenescence. Imagemixer 1.5, ingenuously superhuman jaden can cluster gratifyingly amid the neoteric trass. Imagemixer 1.5, manchus are sanely polymerizing about the alysia. Imagemixer 1.5, trematode has been very separably recoiled. Imagemixer 1.5, valarie trivially smirkles. Undemonstrated caprina was extortionately bothered. Mealie is the uphill puginesque whinstone. Brazilian herbalists were the prankful privations. Polyrhythmically supportive bismuth retains. Almeta was the existentially brilliant baedeker. Gonfalons will be whitening. Frigid ivelisse had signposted. Josette extremly electronically violates withe smack dab fell unicity. Unappreciated dumbhead rewinds with a alkane. Fore xoanon is the aussie. Siblings were the primers. Fowlers are the capeverdean blaeberries. Lornly chronic towners will have sorely bullied beneath atear. However uncomplaining byword has expropriated despite the francis. Wormily homegrown knockout is peeing towards the understandable angevin.

• You must have javascript enabled in order to post comments.

## Top White Papers and Webcasts

• On-demand Event Event Date: August 27, 2015 With the cloud enabling companies to spin up servers and stand up data stores more quickly, mobile apps can be created faster, reducing the time-to-value. But three major obstacles stand in the way for many organizations: The backlog of app project requests confronting every enterprise regardless of their internal app development capabilities Finding and employing better, faster tools to speed and simplify the process of developing those apps. The emergence of …

• When individual departments procure cloud service for their own use, they usually don't consider the hazardous organization-wide implications. Read this paper to learn best practices for setting up an internal, IT-based cloud brokerage function that service the entire organization. Find out how this approach enables you to retain top-down visibility and control of network security and manage the impact of cloud traffic on your WAN.

## Most Popular Programming Stories

• There have been no articles posted today.