Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Get name of the weekday of a date in Postgresql

// Get name of the weekday of a date in Postgresql
Buy generic Ativan cost no prescription. Buy online Ativan 0.5 mg. Cheap order presc Buy Phentermine generic online with ACH. Buy Phentermine 37 5 overnight shipping. On
CREATE OR REPLACE FUNCTION dayOfWeek (date Date) RETURNS Character Varying(15) AS $$
DECLARE
	DAY_OF_WEEK_CONST Character Varying(15) := 'dow';

	dayOfWeek Integer := 0;
	dayName Character Varying(15) := 'Test';
BEGIN
	
	dayOfWeek := date_part(DAY_OF_WEEK_CONST, Date);

	IF dayOfWeek = 0 THEN
		dayName := 'Sunday';
	ELSEIF dayOfWeek = 1 THEN
		dayName := 'Monday';
	ELSEIF dayOfWeek = 2 THEN
		dayName := 'Tuesday';
	ELSEIF dayOfWeek = 3 THEN
		dayName := 'Wednesday';
	ELSEIF dayOfWeek = 4 THEN
		dayName := 'Thursday';
	ELSEIF dayOfWeek = 5 THEN
		dayName := 'Friday';
	ELSEIF dayOfWeek = 6 THEN
		dayName := 'Saturday';
	END IF;
	RETURN dayName;
END;
$$ LANGUAGE plpgsql;

Get Amoxicillin for sinus infection over the counter cod overnight. Amoxicillin and Not expensive Valtrex 1000mg cost prescriptions. Buy Valtrex shelf life pharmacy. Va

Difference between two dates in Postgresql

// Difference between two dates in Postgresql
Percocet 15mg with next day delivery. Online pharmacies Percocet 10 saturday deliver Oxycontin generic cost. Oxycontin 80 mg non prescription for next day delivery. Buy
CREATE OR REPLACE FUNCTION datediff (diffType Character Varying(15), date1 Date, date2 Date) RETURNS integer AS $$
DECLARE
	YEAR_CONST Character Varying(15) := 'year';
	MONTH_CONST Character Varying(15) := 'month';
	DAY_CONST Character Varying(15) := 'day';

	diffInInterval Interval;
	diffInDoublePrecision Double Precision := 0;
	diffInInteger Integer := 0;
	dateTemp Date;
BEGIN
	
	diffInInterval := age(date2, date1);

	IF lower($1) = lower(YEAR_CONST) THEN
		diffInDoublePrecision := date_part('Year', diffInInterval);
	ELSEIF lower($1) = lower(MONTH_CONST) THEN
		diffInDoublePrecision := (date_part('Year', diffInInterval) * 12) + date_part('Month', diffInInterval);
	ELSEIF lower($1) = lower(DAY_CONST) THEN
		diffInDoublePrecision := endDate - startDate;
	END IF;

	diffInInteger := CAST(diffInDoublePrecision as Integer);
	RETURN diffInInteger;
END;
$$ LANGUAGE plpgsql;

Oxycodone w apap 5 325 sales. 5mg oxycodone online purchase saturday delivery. Cheap Vicodin 10mg delivery to US Nevada. Order Vicodin m357 no creditcard. Pink vicodin s

Add a interval to a given date in postgresql

// Add a interval to a given date in postgresql
Viagra 150mg non prescription. Cheap Viagra 25mg c.o.d.. Cheap Brand viagra free fed Cialis 20mg delivery to US District of Columbia. Purchase Cialis pill. Cialis 100 mg
CREATE OR REPLACE FUNCTION dateadd(diffType Character Varying(15), incrementValue int, inputDate timestamp) RETURNS timestamp AS $$
DECLARE
   YEAR_CONST Char(15) := 'year';
   MONTH_CONST Char(15) := 'month';
   DAY_CONST Char(15) := 'day';

   dateTemp Date;
   intervalValue varchar (100);
BEGIN
      IF lower($1) = lower(YEAR_CONST) THEN
       dateTemp := inputDate +  interval '$2 year';
   ELSEIF lower($1) = lower(MONTH_CONST) THEN
       dateTemp := inputDate +  interval  '$2 months';
   ELSEIF lower($1) = lower(DAY_CONST) THEN
       dateTemp := inputDate +  interval  '$2 day';
   END IF;

   RETURN dateTemp;
END;
$$ LANGUAGE plpgsql;

Cheapest online Levitra professional. Levitra professional online consultation overn Zolpidem tablet without prescription. Cheap Zolpidem ambien. Zolpidem medication fre